Communication device, control method of communication device, and program

ABSTRACT

A communication procedure for providing or receiving communication parameters can be performed by an easy operation even between devices having both a base station function and a slave station function. A communication device of the present invention determines a role of a device when performing a predetermined communication procedure for providing or receiving communication parameters, and selects operating as a base station or operating as a slave station based on the determined role. The communication device selects based on the determined role operating as a providing device or operating as a receiving device.

CROSS-REFERENCE TO RELATED APPLICATION

This application Continuation of U.S. application Ser. No. 14/311,900, filed Jun. 23, 2014; which is a Continuation of U.S. application Ser. No. 13/319,565, filed Nov. 9, 2011, now becomes U.S. Pat. No. 8,798,020, issued Aug. 5, 2014; which is a National Phase application of International Application PCT/JP2010/002895, filed Apr. 22, 2010, which claims priority from Japanese Patent Application No. 2009-118973 filed May 15, 2009, which is hereby incorporated by reference herein in its entirety.

TECHNICAL FIELD

The present invention relates to a communication device, a control method of the communication device, and a program.

BACKGROUND ART

In recent years, devices having functions both as an access point (AP) of infrastructure communication of wireless local area network (LAN) compliant with IEEE802.11 series, and as a station (STA) which connects and communicates with the AP, have come on the market. Such a device can construct a network as an AP, and also can participate in a network constructed by other APs as an STA.

An example of communication device which can switch the role of the device (base device, slave device) is discussed in Japanese Patent Application Laid-Open No. 2006-005844 and Japanese Patent Application Laid-Open No. 2003-152730.

An example of communication device in which a function of a relay station (access point) and a function of a station are operated at the same time is discussed in U.S. Pat. No. 7,362,722 (Japanese Patent Application Laid-Open No. 2005-086350).

When AP and STA communicate with each other, there are many setting items which need to be set before use. For example, the setting items include communication parameters to perform wireless communication, such as a service set identifier (SSID) as a network identifier, an encryption method, an encryption key, an authentication method, and an authentication key. To set these communication parameters, automatic setting methods for simply setting communication parameters to a wireless communication device are devised by various manufacturers. In these automatic setting methods, communication parameters are automatically set by providing communication parameters from one device to another device using a procedure and a message predetermined between the devices to be connected to each other.

Non Patent Literature 1 discusses Wi-Fi protected setup (hereinafter, WPS), which is an industry standard of a communication parameter automatic setting method between AP and STA.

When performing wireless communication between the devices having both functions of the AP function and the STA function, the communication is possible when one device constructs a network as an AP and the other device connects to the network as an STA. When devices, which are in an initial state and operate neither as AP nor as STA, try to communicate with each other, the roles of the devices need to be determined, for example, a device which becomes AP is determined.

In this case, when user's convenience is considered, it is desired that the determination of the roles is automatically performed between the devices. However, a method in which the roles are automatically determined between the devices without requiring user's operation has not been established. Therefore, when the devices have both the AP function and the STA function, the automatic setting processing of communication parameters cannot be performed, so that there is a problem that the devices operating both as AP and as STA cannot easily communicate with each other.

CITATION LIST Non Patent Literature [NPL 1]

-   Wi-Fi CERTIFIED™ for Wi-Fi Protected Setup: Easing the User     Experience for Home and Small Office Wi-Fi® Networks,     http://www.wi-fi.org/wp/wifi-protected-setup

SUMMARY OF INVENTION

The present invention is directed to a communication method in which a communication procedure for providing or receiving communication parameters can be performed by an easy operation even between devices having both a base station function and a slave station function.

According to an aspect of the present invention, a communication method determines a role of a device when performing a predetermined communication procedure for providing or receiving communication parameters, selects operating as a base station or operating as a slave station based on the determined role, selects based on the determined role operating as a providing device or operating as a receiving device.

Further features and aspects of the present invention will become apparent from the following detailed description of exemplary embodiments with reference to the attached drawings.

BRIEF DESCRIPTION OF DRAWINGS

The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate exemplary embodiments, features, and aspects of the invention and, together with the description, serve to explain the principles of the invention.

FIG. 1A is a block diagram illustrating a configuration of a device according to an exemplary embodiment of the present invention.

FIG. 1B is a block diagram illustrating a configuration of a device according to an exemplary embodiment of the present invention.

FIG. 2A is a network configuration diagram of an exemplary embodiment of the present invention.

FIG. 2B is a network configuration diagram of an exemplary embodiment of the present invention.

FIG. 3 is a flowchart illustrating a communication processing of a device A and a device B according to a first exemplary embodiment of the present invention.

FIG. 4A is a sequence diagram illustrating an operation of the device A and the device B according to the first exemplary embodiment of the present invention.

FIG. 4B is a sequence diagram illustrating an operation of the device A and the device B according to the first exemplary embodiment of the present invention.

FIG. 5 is a flowchart illustrating a communication processing of the device A and the device B according to a second exemplary embodiment of the present invention.

FIG. 6 is a sequence diagram illustrating an operation of the device A and the device B according to the second exemplary embodiment of the present invention.

DESCRIPTION OF EMBODIMENTS

Various exemplary embodiments, features, and aspects of the invention will be described in detail below with reference to the drawings.

Hereinafter, although an example which uses a wireless LAN system compliant with IEEE802.11 series will be described, a communication method is not limited to a wireless LAN compliant with IEEE802.11.

FIG. 1A is a hardware block diagram illustrating a configuration example of devices described below according to an exemplary embodiment to which the present invention can be applied. The device 101 is an entire device. A control section 102 controls the entire device by executing a control program stored in a storage section 103. The control section 102 performs a communication parameter setting control between the device and another device. A storage section 103 stores the control program executed by the control section 102 and various information such as a communication parameter. Various operations described below are performed when the control section 102 executes the control program stored in the storage section 103. A wireless section 104 is for performing wireless communication. A display section 105 displays various information and has a function of outputting visible information as a liquid crystal display (LCD) and a light-emitting diode (LED) and a function of outputting audio information as a speaker.

A setting button 106 is a button to provide a trigger to start communication parameter setting processing. When the control section 102 detects an operation of the setting button 106 by a user, the control section 102 performs processing described below. An antenna control section 107, and an antenna 108 are illustrated in FIG. 1A. An input section 109 is a section for a user to input various information.

FIG. 1B is a block diagram illustrating an example of a configuration of software function blocks performed by the devices in the communication parameter setting processing described below. A device 201 is an entire device. A packet receiving section 202 is a section for receiving packets of various communication. Beacon (notification signal) is received by the packet receiving section 202. Also, a device search signal such as a probe request is received by the packet receiving section 202. The probe request can be treated as a network search signal for searching a desired network. A probe response which is a response signal to the probe request is also received by the packet receiving section 202.

A packet transmitting section 203 is a section for transmitting packets of various communication. Transmission of beacon is performed by the packet transmitting section 203. The probe request and the probe response which is a response signal to the probe request are also transmitted by the packet transmitting section 203. Various information (self-information) of a transmission source device is added to the device search signal and the response signal thereto. An AP control section is a section for controlling an access point (AP) communication function. An operation as an access point (AP) described below is performed by using the AP control section 204. The AP is a base station (base device, master station) which performs various controls of wireless network. The AP is a device which establishes a network by itself when performing communication and performs various controls in response to a connection request from a station (STA). The AP transmits a beacon periodically when performing communication, and when receiving a connection request signal transmitted from an STA, the AP transmits a connection request response signal to the STA to connect with the STA.

An STA control section 205 is a section for controlling an STA communication function. An operation as a station (STA) described below is performed by using the STA control section 205. The STA is a slave station (slave device, mobile device) in a wireless network, and connects to the AP when performing communication. When performing communication, the STA transmits a connection request signal to an AP, receives a connection request response signal from the AP to connect with the AP, and performs communication under the control of the AP. As described in a second exemplary embodiment, wireless LAN ad-hoc communication in which two STAs communicate with each other directly can be performed by using the STA control section 205.

A network detection section 206 is a section for detecting a network present in surrounding areas. A device can detect a network present in surrounding areas by receiving a beacon or a probe response from a device in surrounding areas via the packet receiving section 202. It is also possible to detect an AP, which is constructing a network, by using the network detection section 206. An AP detection operation described below is performed by using the network detection section 206. A communication parameter providing section 207 is a section for providing a communication parameter to a device on the other side of communication. Communication parameter automatic setting described below is provided by the communication parameter providing section 207. The communication parameter providing section 207 provides communication parameters necessary for performing wireless communication, such as an SSID as a network identifier, an encryption method, an encryption key, an authentication method, and an authentication key. A communication parameter receiving section 208 is a section for receiving a communication parameter from the device on the other side of communication. Communication parameter automatic setting described below is received by the communication parameter receiving section 208.

A role determination section 209 is a section for determining a device which manages network when performing communication between devices. Role determination processing described below is performed by the role determination section 209. By the role determination processing, either role of “management device” or “terminal device” is provided to each device. A device to which the role of management device is provided operates as an AP by using the AP control section 204, and provides communication parameters to the terminal by the parameter providing section 207. On the other hand, a device to which the role of the terminal device is provided operates as an STA by using the STA control section 205, and receives communication parameters from the AP by the parameter receiving section 208.

A switching section 210 is a section for switching between operating as an AP using the AP control section 204, and operating as an STA using the STA control section 205, and selects the switched operation. The switching section 210 performs a first switching according to a role determined by the role determination section 209, a second switching according to a detection result detected by the network detection section 206, and the like.

A selection section 211 is a section for selecting between operating as a providing device which provides a communication parameter using the communication parameter providing section 207, and operates as a receiving device using the communication parameter receiving section 208. The selection section 211 performs a selection according to the role determined by the role determination section 209.

FIGS. 2A and 2B are diagrams illustrating network constructions of a communication device-A 300 (hereinafter, device A) and a communication device-B 301 (hereinafter, device B). These devices have configurations illustrated in FIGS. 1A and 1B.

When the device A and the device B operate as an AP, the device A and the device B respectively establish a network-A 302 (hereinafter, network A) and a network-B 303 (hereinafter, network B) (FIG. 2A). After the device A and the device B detect each other, one of the devices participates in a network established by the other device, and the devices exchange messages for determining the management device. At this time, all communication parameters are not set, but some communication parameters by which the messages for determining the role can be exchanged are set. More specifically, a network identifier is stored in a signal (beacon, probe request, and probe response) used for device detection processing.

A device which tries to participate in the network sets a network identifier of the network in which the device tries to participate, and thereafter performs participation processing. The encryption method and the encryption key have not been set yet. The device which becomes the management device as a result of the exchange of the messages establishes a network 401 as an AP, and provides communication parameters to the STA by automatic setting of communication parameters (FIG. 2B).

The STA which has received the communication parameters participates in the network by using the received communication parameters. The communication parameter providing processing (receiving processing) is performed by, for example, a communication parameter automatic setting procedure such as Wi-Fi Protected Setup between devices. The communication parameter automatic setting procedure is a communication procedure by which the providing device provides communication parameters to the receiving device and the receiving device receives the communication parameters from the providing device. This procedure is performed by exchanging predetermined messages between the devices.

FIG. 3 is a flowchart illustrating an example of an operation flow of communication processing performed between the device A and the device B when the setting button 106 is pressed. This operation is performed when the control section 102 reads the control program stored in the storage section 103 and controls the wireless section 104 or the like. Hereinafter, a control performed by both devices will be described along the flowchart.

In the device in which the setting button 106 is pressed, the control section 102 starts the role determination section 209. In step S501, the role determination section 209 performs processing to search an access point (AP) present in surrounding areas by using the network detection section 206. In step S502, the role determination section 209 checks information included in a received beacon or probe response, and checks whether there is an AP which is performing the roll determination processing.

In step S510, when there is at least one AP which is performing the roll determination processing, the role determination section 209 checks whether there is one AP or more than one APs which are performing the roll determination processing. In step S512, when more than one APs which are performing the roll determination processing are detected, an error notification informing a user of an error is displayed on the display section 105, and the role determination section 209 ends the processing due to an error.

In step S511, when there is one AP which is performing the roll determination processing, the role determination section 209 connects to the network constructed by the detected AP using the STA control section 205.

In step S503, when there is no AP which is performing the roll determination processing, the role determination section 209 starts an access point operation using the AP control section 204. When the AP control section 204 starts the access point operation, the AP control section 204 adds self-information indicating that the AP control section itself is performing the role determination processing, to a beacon and a probe response, and transmits the beacon and the probe response.

In step S504, the role determination section 209 exchanges arbitration messages with the device on the other side, and determines which device becomes the management device. As an example of the determination processing in step S504, it is possible to use a method of including information indicating a priority of the management device in the arbitration message and transmitting the arbitration message. In this case, by comparing the priority included in the arbitration message received from the device on the other side and the priority of the device itself, a device having a higher priority is determined to be the management device. The priority of the management device is determined based on information such as a device type of the device, a remaining battery level, manufacturer information, universally unique identifier (UUID), and media access control (MAC) address.

When the device itself is operating as an access point, a priority higher than a case where it is operating as a station, may be set. Also, the priority information may be set based on connectivity to other networks, such as whether the device itself can be connected to the Internet. Further, when the priority of the device on the other side and the priority of the device itself are the same, by comparing information unique to a device such as UUID and MAC address, a device which satisfies a predetermined condition may be determined to be the management device.

In step S505, after determining the role, the control section 102 checks whether the determined role of the device itself is the management device. In step S506, when the device itself is determined to be the management device, the control section 102 checks whether the device itself is operating as an AP. If operating as an AP, the processing proceeds to step S509. If not operating as an AP, the control section 102 separates from the network connected by the STA control section 205 in step S507. In step S508, after separating from the network, the control section 102 starts an access point operation by using the AP control section 204. In step S509, thereafter, the control section 102 starts processing to provide communication parameters to the receiving device using the communication parameter providing section 207. The communication parameter providing processing is performed by performing the communication parameter automatic setting procedure between the providing device and the receiving device.

If the device itself is determined to be the terminal device as a result of the role determination, the control section 102 checks whether the device itself is operating as an AP in step S513. If not operating as an AP, the processing proceeds to step S515. If operating as an AP, the control section 102 stops the access point operation in step S514. In step S515, after stopping the access point operation, the control section 102 operates as a receiving device using the communication parameter receiving section 208, and starts processing to receive the communication parameters from the providing device.

In step S516, after starting the processing, the control section 102 performs a search of an AP using the network detection section 206. As a result of the search, if more than one APs which are performing the communication parameter providing processing are detected in step S517, the processing proceeds to step S512, displays an error notification informing a user of an error on the display section 105, and ends the process due to an error. If there is one AP which is performing the communication parameter providing processing in step S517, the control section 102 connects to the AP in step S518, and, as a receiving device which receives the communication parameters from a providing device, the control section 102 performs a predetermined communication parameter automatic setting procedure with the AP.

FIGS. 4A and 4B are an example of a processing sequence in which the setting button 106 is pressed in the device A and the device B, and the communication parameter automatic setting processing is performed between the device A and the device B.

FIG. 4A is an example illustrating a processing sequence in which the setting button 106 is pressed in the device A and the device B, the roles are determined between the device A and the device B, and the device B becomes the management device to perform the communication parameter automatic setting processing.

When the setting button 106 of the device B is pressed, the device B performs the processing of FIG. 3. The device B transmits a device search signal (probe request), and checks whether there is an AP which is performing the roll determination processing in areas around the device B (F601). In this case, since there is no AP which is performing the roll determination processing in areas around the device B, the device B starts the access point operation to construct a network B (F602).

Thereafter, when the setting button 106 of the device A is pressed, the device A performs the processing of FIG. 3. The device A transmits a device search signal, and checks whether there is an AP which is performing the roll determination processing in areas around the device A (F603). The device search signal, which is an AP performing the roll determination processing, transmits a device search response signal (probe response) responding to the device search signal transmitted from the device A (F604). The device A receives the device search response signal from the device B, and recognizes that the device B is an AP which is performing the roll determination processing by checking the additional information in the signal. After recognizing that, the device A transmits a connection request signal to the device B, which is an AP performing the roll determination processing (F605).

The device B returns a connection request response signal indicating connection permission to the device A (F606). When the device A receives the connection request response signal from the device B, the device A connects to the device B and exchanges role arbitration messages to determine the management device (F607, F608). Each device refers to the other device's priority information included in the role arbitration message, and determines the management device by comparing the priority information with priority information of its own. In this case, it is assumed that the device B becomes the management device.

After determining the role, the device B starts the communication parameter providing processing (F609). On the other hand, the device A starts the communication parameter receiving processing (F610). Since the device A has already connected to the device B, the device A transmits a message indicating a start of the communication parameter setting to the device B (F613). Then, the communication parameter setting processing is performed by exchanging protocol messages for the automatic setting procedure between the device A which is a receiving device and the device B which is a providing device (F614). As a result, communication parameters are transmitted from the device B to the device A, and the device B transmits a message indicating the completion of the communication parameter setting to the device A (F615).

In this way, the communication parameter setting processing is completed. The device A sets the communication parameters (a network identifier (SSID), an encryption method, an encryption key, an authentication method, and an authentication key) received from the device B, and performs the communication connection processing again on the device B (F616). The communication protocol processing of the communication parameter setting processing can be realized by using communication protocol processing specified by industry standard communication parameter setting processing as discussed in Non Patent Literature 1.

Next, a case in which a device operating as an STA during the role determination processing becomes the management device and provides communication parameters will be described.

FIG. 4B is an example of a processing sequence in which the setting button 106 is pressed in the device A and the device B, the roles are determined between the device A and the device B, and the device A becomes the management device to perform the communication parameter automatic setting processing.

When the setting button 106 of the device B is pressed, the device B performs the processing of FIG. 3. The device B transmits the device search signal, and checks whether there is an AP which is performing the roll determination processing in areas around the device B (F701). In this case, since there is no AP which is performing the roll determination processing in areas around the device B, the device B starts the access point operation to construct a network B (F702).

Thereafter, when the setting button 106 of the device A is pressed, the device A performs the processing of FIG. 3. The device A transmits a device search signal (probe request), and checks whether there is an AP which is performing the roll determination processing in areas around the device A (F703). The device B, which is an AP performing the roll determination processing, transmits a device search response signal (probe response) responding to the device search signal transmitted from the device A (F704).

The device A receives the device search response signal from the device B, and recognizes that the device B is an AP which is performing the roll determination processing by checking the additional information in the signal. After recognizing that, the device A connects to the device B (F705, F706), and exchanges role arbitration messages to determine the management device (F707, F708). Each device compares the other device's priority information included in the role arbitration message with the priority information of its own, and determines the management device. In this case, it is assumed that the device A becomes the management device.

After determining the role, the device A starts the access point operation and constructs a network A (F709). After starting the access point operation, the device A starts the communication parameter providing processing (F710). On the other hand, the device B stops the access point operation (F711), and starts the communication parameter receiving processing (F712). The device B transmits a connection request signal to the device A which is the management device and the AP (F713). The device A returns a connection request response signal indicating connection permission to the device B (F714).

When the device B receives the connection request response signal from the device A, the device B connects to the device A and transmits a message indicating a start of the communication parameter setting (F715), and the communication parameter setting processing is performed between the device B which is the receiving device and the device A which is the providing device (F716). As a result, communication parameters are transmitted from the device A to the device B, and the device A transmits a message indicating the completion of the communication parameter setting to the device B (F717). In this way, the communication parameter setting processing is completed. The device B sets the communication parameters (i.e., a network identifier (SSID), an encryption method, an encryption key, an authentication method, and an authentication key) received from the device A, and performs the communication connection processing again to the device A (F718).

As described above, even a device having both functions of a base station and a slave station can determine a device that operates as a base station and a device that operates as a slave station. The device can also determine a device that operates as a communication parameter providing device and a device that operates as a communication parameter receiving device. Therefore, even when using a device having both functions of a base station and a slave station, if a user performs an operation such as pressing the setting button 106, the communication parameter setting processing can be performed between devices. Further, by performing the communication parameter setting processing, setting shared communication parameters, and performing authentication processing between devices, it is possible to perform encrypted wireless communication.

As a second exemplary embodiment, a case in which the role determination processing is performed by wireless LAN ad-hoc communication will be described. The ad-hoc communication is wireless communication performed directly between stations without using an access point. The device configuration is the same as that in FIGS. 1A and 1B.

FIG. 5 is a flowchart illustrating an example of an operation flow of communication processing performed between the device A and the device B when the setting button 106 is pressed. This operation is performed when the control section 102 reads the control program stored in the storage section 103 and controls the wireless section 104 or the like. Hereinafter, a control performed by both devices will be described along the flowchart.

In the device in which the setting button 106 is pressed, the control section 102 starts the role determination section 209. In step S801, the device constructs an ad-hoc network by using the STA control section 205. When the STA control section 205 constructs the ad-hoc network, the STA control section 205 adds self-information indicating that the STA control section itself is performing the role determination processing, to a beacon and a probe response.

After constructing the ad-hoc network, in step S802, the role determination section 209 performs processing to search an ad-hoc network present in surrounding areas by using the network detection section 206. In step S803, the role determination section 209 checks information included in a received beacon or a probe response, and checks whether there is an ad-hoc network which is performing the roll determination processing. In step S804, when there is at least one ad-hoc network which is performing the roll determination processing, the role determination section 209 checks whether there is one ad-hoc network or more than one ad-hoc networks which are performing the roll determination processing.

In step S813, when there are more than one ad-hoc networks which are performing the roll determination processing, an error notification informing a user of an error is displayed on the display section 105, and the processing ends due to an error. In step S805, when there is one ad-hoc network which is performing the roll determination processing, the role determination section 209 participates in the ad-hoc network by using the STA control section 205. When it participates in the network, the role determination section 209 stops the ad-hoc network constructed in step S801. After participating in the ad-hoc network, the role determination section 209 exchanges arbitration messages with the device on the other side in step S806, and determines which device becomes the management device in step S807.

In step S811, when there is no ad-hoc network which is performing the roll determination processing, the role determination section 209 waits for an role arbitration message transmitted from another device on the ad-hoc network constructed by the role determination section 209 itself. In step S802, when the role determination section 209 does not receive an role arbitration message in step S811, the role determination section 209 searches an ad-hoc network present in surrounding areas by using the network detection section 206 again.

When receiving a role arbitration message in step S811, the role determination section 209 transmits a role arbitration message to the transmission source device of the received role arbitration message in step S812, and determines which device becomes the management device in step S807. As an example of the determination processing, it is possible to use a method of including priority information of the management device in the arbitration message and transmitting the arbitration message. In this case, by comparing the priority included in the arbitration message received from the device on the other side and the priority of the device itself, a device having a higher priority is determined to be the management device.

The priority of the management device is determined based on information such as a device type including a printer, a camera, and the like, service information included in the device itself, manufacturer information, UUID, and MAC address. The priority information may also be set based on a remaining battery level. Also, the priority information may be set based on connectivity to other networks, such as whether the device itself can be connected to the Internet. When the priority of the device on the other side and the priority of the device itself are the same, the management device may be determined based on device unique information such as UUID and MAC address.

After determining the role, in step 808, the control section 102 checks whether the determined role of itself is the management device. In step S809, when the control section 102 determines itself to be the management device, the control section 102 starts an access point operation by using the AP control section 204. Thereafter, in step S810, the control section 102 starts processing to provide communication parameters to the receiving device by using the communication parameter providing section 207. When the receiving device is connected, as a providing device, the control section 102 performs a predetermined communication parameter automatic setting procedure with the receiving device, and performs the communication parameter providing processing.

After the check in step S808, when the control section 102 determines itself to be the terminal device, the control section 102 starts processing to receive the communication parameters from the providing device using the communication parameter receiving section 208 in step S814. Then, in step S815, the control section 102 searches an access point by using the network detection section 206. As a result of the search, in step 816, when more than one APs which are performing the communication parameter providing processing are detected, the processing proceeds to step S813, displays an error notification informing a user of an error on the display section 105, and ends the process due to an error.

When there is one AP which is performing the communication parameter providing processing in step S816, the control section 102 connects to the AP in step S817, and, as a receiving device which receives the communication parameters from a providing device, the control section 102 performs a predetermined communication parameter automatic setting procedure together with the AP which is the providing device.

FIG. 6 is an example illustrating a processing sequence in which the setting button 106 is pressed in the device A and the device B, the roles are determined between the device A and the device B, and thereafter the device A becomes the management device to perform the communication parameter automatic setting processing.

When the setting button 106 of the device B is pressed, the device B performs the processing of FIG. 5. The device B constructs an ad-hoc network B (F901), transmits a device search signal (probe request) (F902), searches a device which is performing the roll determination processing in surrounding areas, and searches an ad-hoc network in surrounding areas.

When the setting button 106 of the device A is pressed, the device A performs the processing of FIG. 5. The device A constructs an ad-hoc network A (F903), transmits a device search signal (F904), searches a device which is performing the roll determination processing in surrounding areas, and searches an ad-hoc network in surrounding areas. The device B transmits a device search response signal (probe response) responding to the device search signal transmitted from the device A (F905). The device A receives the device search response signal from the device B, and recognizes that the device B is performing the roll determination processing by checking the additional information in the signal.

After recognizing that, the device A stops the network A and participates in the network B (F906), and then transmits a role arbitration message to determine the management device, to the device B (F907). The device B, which receives the role arbitration message from the device A, transmits a role arbitration message to the device A (F908). Each device refers to the other device's priority information included in the role arbitration message, and determines the management device. In this case, it is assumed that the device A becomes the management device.

After determining the role, the device A starts the access point operation and constructs a network C (F909). After constructing the network, the device A starts the communication parameter providing processing (F910). On the other hand, the device B stops the network B (F911), and starts the communication parameter receiving processing (F912). The device B searches a network in surrounding areas, searches an AP which is performing the communication parameter providing processing, and detects the device A. The device B transmits a connection request signal to the device A to request a connection (F913).

When the device A receives the connection request signal from the device B, the device A returns a connection request response signal indicating connection permission to the device B (F914). When receiving the response signal, the device B connects to the device A, transmits a message indicating a start of the communication parameter setting to the device A (F915), and requests to start the communication parameter automatic setting processing. Then, the communication parameter setting processing is performed between the device B which is the receiving device and the device A which is the providing device (F916). As a result, communication parameters are transmitted from the device A to the device B, and the device A transmits a message indicating the completion of the communication parameter setting to the device B (F917). In this way, the communication parameter setting processing is completed.

The device B sets the communication parameters (i.e., a network identifier (SSID), an encryption method, an encryption key, an authentication method, and an authentication key) received from the device A, and performs the communication connection processing again on the device A (F918).

As described above, even a device having both functions of a base station and a slave station can determine a device that operates as a providing device of communication parameters and a device that operates as a receiving device of communication parameters. A device determined to be the providing device can operate as the base station, and perform the communication parameter automatic setting processing. Therefore, even when using a device having both functions of a base station and a slave station, if a user performs an operation such as pressing the setting button 106, the communication parameter setting processing can be performed between devices. Further, by performing the communication parameter setting processing, setting shared communication parameters, and performing authentication processing between devices, it is possible to perform encrypted wireless communication.

The exemplary embodiments of the present invention have been described above. However, the exemplary embodiments are only examples for description of the present invention, and the scope of the present invention is not intended to be limited to the exemplary embodiments. The exemplary embodiments can be variously modified without departing from the scope of the present invention.

The above description is made using an example of wireless LAN compliant with IEEE802.11. However, the present invention may be implemented in other wireless media such as wireless universal serial bus (USB), MBOA, Bluetooth (registered trademark), ultra wideband (UWB), and ZigBee. Also, the present invention may be implemented in wired communication media such as wired LAN. Here, the MBOA is an abbreviation of Multi Band OFDM Alliance. The UWB includes wireless USB, wireless 1394, WINET, and the like.

While the present invention has been described with reference to exemplary embodiments, it is to be understood that the invention is not limited to the disclosed exemplary embodiments. The scope of the following claims is to be accorded the broadest interpretation so as to encompass all modifications, equivalent structures, and functions. 

What is claimed is:
 1. A communication device comprising: a base station unit configured to operate as a base station; a station unit configured to operate as a station which is connected to a base station; a providing unit configured to operate as a providing device that provides a communication parameter; a receiving unit configured to operate as a receiving device that receives a communication parameter from a providing device; a setting unit configured to set a value for determining a first role operating as a base station and a providing device of a communication parameter and a second role operating as a station and a receiving device of a communication parameter; and a determination unit configured to determine that a role of the communication device is the first role or the second role based on determination processing to compare the value set using the setting unit with a value received from another communication device, wherein the setting unit is configured to set a different value based on whether the station unit operates as a station when the determination processing is performed.
 2. The communication device according to claim 1, further comprising: a transmission unit configured to transmit the value set using the setting unit.
 3. The communication device according to claim 2, further comprising: a search unit configured to search another communication device, wherein the transmission unit is configured to transmit the value set using the setting unit in a case where the other communication device searched using the search unit can execute role determination processing for determining roles between the other communication device and a device other than that.
 4. The communication device according to claim 1, comprising: a notification unit configured to notify an error when more than one device that are performing processing for sharing communication parameters are detected.
 5. The communication device according to claim 1, wherein, in a case that the communication device operates as a base station using the base station unit, the communication device sends a beacon.
 6. The communication device according to claim 1, wherein the communication parameters include at least one of an encryption method, an encryption key, an authentication method, and an authentication key.
 7. The communication device according to claim 1, wherein the communication parameters include a network identifier, an encryption method, an encryption key, an authentication method, and an authentication key.
 8. The communication device according to claim 1, wherein communication based on an operation as a base station using the base station unit, communication based on an operation as a station using the station unit, communication for providing a communication parameter using the providing unit, and communication for receiving a communication parameter using the receiving unit are wireless communication.
 9. The communication device according to claim 1, wherein communication based on an operation as a base station using the base station unit, communication based on an operation as a station using the station unit, communication for providing a communication parameter using the providing unit, and communication for receiving a communication parameter using the receiving unit are communication compliant with IEEE802.11 series.
 10. The communication device according to claim 1, wherein the providing unit is configured to provide a communication parameter by Wi-Fi Protected Setup, and wherein the receiving unit is configured to receive a communication parameter by Wi-Fi Protected Setup.
 11. The communication device according to claim 1, wherein a role of the communication device is determined to be the first role in a case where the value set using the setting unit is higher than the value of the other communication device, and a role of the communication device is determined to be the second role in a case where the value set using the setting unit is lower than a priority of the other communication device.
 12. The communication device according to claim 11, wherein a role of the communication device is determined to be the first role or the second role based on information different from the value set using the setting unit and the value of the other communication device in a case where the value set using the setting unit and the value of the other communication device are the same.
 13. The communication device according to claim 12, wherein the information is information on the communication device, and wherein the determination unit is configured to determine that a role of the communication device is the first role in a case where the information satisfies a predetermined condition, and to determine that a role of the communication device is the second role in a case where the information does not satisfy the predetermined condition.
 14. The communication device according to claim 1, wherein the setting unit is configured to set a value to be set when the station unit does not operate as a station larger than a value to be set when the station unit operates as a station.
 15. A control method performed by a communication device comprising a base station unit configured to operate as a base station, a station unit configured to operate as a station which is connected to the base station, a providing unit configured to operate as a providing device that provides a communication parameter, and a receiving unit configured to operate as a receiving device that receives a communication parameter, the control method comprising: setting a value for determining a first role operating as a base station and a providing device of a communication parameter and a second role operating as a station and a receiving device of a communication parameter; and determining that a role of the communication device is the first role or the second role based on determination processing to compare the set value set with a value received from another communication device, wherein the setting sets a different value based on whether the station unit operates as a station when the determination processing is performed.
 16. A computer-readable storage medium storing a computer program for causing a computer to execute a control method performed by a communication device comprising a base station unit configured to operate as a base station, a station unit configured to operate as a station which is connected to the base station, a providing unit configured to operate as a providing device that provides a communication parameter, and a receiving unit configured to operate as a receiving device that receives a communication parameter, the control method comprising: setting a value for determining a first role operating as a base station and a providing device of a communication parameter and a second role operating as a station and a receiving device of a communication parameter; and determining that a role of the communication device is the first role or the second role based on determination processing to compare the set value set with a value received from another communication device, wherein the setting sets a different value based on whether the station unit operates as a station when the determination processing is performed.
 17. A communication device comprising: a base station unit configured to operate as a base station; a station unit configured to operate as a station which is connected to a base station; a providing unit configured to operate as a providing device that provides a communication parameter; a receiving unit configured to operate as a receiving device that receives a communication parameter from a providing device; a setting unit configured to set a value for determining a first role operating as a base station and a providing device of a communication parameter and a second role operating as a station and a receiving device of a communication parameter; and a determination unit configured to determine that a role of the communication device is the first role or the second role based on determination processing to compare a value set using the setting unit with a value received from another communication device, wherein the setting unit is configured to set a different value based on whether the base station unit operates as a base station when the determination processing is performed.
 18. A communication device comprising: a base station unit configured to operate as a base station; a station unit configured to operate as a station which is connected to a base station; a providing unit configured to operate as a providing device that provides a communication parameter; a receiving unit configured to operate as a receiving device that receives a communication parameter from a providing device; a setting unit configured to set a value for determining a first role operating as a base station and a providing device of a communication parameter and a second role operating as a station and a receiving device of a communication parameter; and a determination unit configured to determine that a role of the communication device is the first role or the second role based on determination processing to compare a value set using the setting unit with a value received from another communication device, wherein the setting unit is configured to set a different value based on whether the communication device is connected to a predetermined network when the determination processing is performed.
 19. The communication device according to claim 18 wherein the predetermined network is internet.
 20. The communication device according to claim 18, wherein the setting unit is configured to set a value to be set when the communication device is connected to the predetermined network larger than a value to be set when the communication device is not connected to the predetermined network. 